﻿using System;
using System.Collections;
using Huirui.Cavan.Domain.MainBoundedContext.SystemModule;
using System.Collections.Generic;
using Huirui.Cavan.Domain.Seedwork;

namespace Huirui.Cavan.Domain.MainBoundedContext.SalesModule
{
    #region Receipt

    /// <summary>
    /// Receipt object for NHibernate mapped table 'Receipt'.
    /// </summary>
    [Serializable]
    public class Receipt : Persistent<string>
    {
        #region Member Variables

        protected DateTime _receiptDate;
        protected Account _toAccount;
        protected string _accountNumber;
        protected decimal _amount;
        protected decimal _discount;
        protected string _currency;
        protected decimal _currencyRate;
        protected Employee _receiptEmployee;
        protected string _remark;
        protected Corporation _corporation;
        protected Customer _customer;
        protected IList<ReceiptDetail> _receiptDetails;

        #endregion

        #region Constructors

        public Receipt() { }

        public Receipt(string id, DateTime receiptDate, Account toAccount, string accountNumber, decimal amount, decimal discount, string currency, decimal currencyRate, Employee receiptEmployee, string remark, DateTime createDate, DateTime modifyDate, int editUser, Corporation corporation, Customer customer)
        {
            this.Id = id;
            this._receiptDate = receiptDate;
            this._currency = currency;
            this._currencyRate = currencyRate;
            this._receiptEmployee = receiptEmployee;
            this._remark = remark;
            this._createDate = createDate;
            this._modifyDate = modifyDate;
            this._editUser = editUser;
            this._corporation = corporation;
            this._customer = customer;
            this._toAccount = toAccount;
            this._accountNumber = accountNumber;
            this._amount = amount;
            this._discount = discount;
        }

        #endregion

        #region Public Properties


        public virtual DateTime ReceiptDate
        {
            get { return _receiptDate; }
            set { _receiptDate = value; }
        }

        public virtual Account ToAccount
        {
            get { return _toAccount; }
            set { _toAccount = value; }
        }

        public virtual string AccountNumber
        {
            get { return _accountNumber; }
            set { _accountNumber = value; }
        }

        public virtual decimal Amount
        {
            get { return _amount; }
            set { _amount = value; }
        }

        public virtual decimal Discount
        {
            get { return _discount; }
            set { _discount = value; }
        }

        public virtual string Currency
        {
            get { return _currency; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for CurrencyCode", value, value.ToString());
                _currency = value;
            }
        }

        public virtual decimal CurrencyRate
        {
            get { return _currencyRate; }
            set { _currencyRate = value; }
        }

        public virtual Employee ReceiptEmployee
        {
            get { return _receiptEmployee; }
            set
            {
                _receiptEmployee = value;
            }
        }

        public virtual string Remark
        {
            get { return _remark; }
            set
            {
                _remark = value;
            }
        }

        public virtual Corporation Corporation
        {
            get { return _corporation; }
            set { _corporation = value; }
        }

        public virtual Customer Customer
        {
            get { return _customer; }
            set { _customer = value; }
        }

        public virtual IList<ReceiptDetail> ReceiptDetails
        {
            get
            {
                if (_receiptDetails == null)
                {
                    _receiptDetails = new List<ReceiptDetail>();
                }
                return _receiptDetails;
            }
            set { _receiptDetails = value; }
        }
        #endregion
    }
    #endregion
}